package com.example.shop.service.impl;

import com.example.shop.entity.Orders;
import com.example.shop.dao.OrdersMapper;
import com.example.shop.service.OrdersService;
import org.springframework.stereotype.Service;
import jakarta.annotation.Resource;

import java.util.List;

/**
 * (Orders)表服务实现类
 *
 * @author makejava
 * @since 2025-03-26 09:26:22
 */
@Service("ordersService")
public class OrdersServiceImpl implements OrdersService {
    @Resource
    private OrdersMapper ordersMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param orderid 主键
     * @return 实例对象
     */
    @Override
    public Orders queryById(Integer orderid) {
        return this.ordersMapper.queryById(orderid);
    }


    /**
     * 新增数据
     *
     * @param orders 实例对象
     * @return 实例对象
     */
    @Override
    public Orders insert(Orders orders) {
        this.ordersMapper.insert(orders);
        return orders;
    }

    /**
     * 修改数据
     *
     * @param orders 实例对象
     * @return 实例对象
     */
    @Override
    public Orders update(Orders orders) {
        this.ordersMapper.update(orders);
        return this.queryById(orders.getOrderid());
    }

    /**
     * 通过主键删除数据
     *
     * @param orderid 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer orderid) {
        return this.ordersMapper.deleteById(orderid) > 0;
    }

    @Override
    public List<Orders> queryAll() {
        return null;
    }
}
